//
//  YJTagView.m
//  CToolBox
//
//  Created by crj on 2017/9/5.
//  Copyright © 2017年 SC. All rights reserved.
//

#import "YJTagView.h"

#define tagSideSpace 1

@implementation YJTagView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}



- (void)reloadWithText:(NSString *)text
    tagBackgroundColor:(UIColor *)tagBackgroundColor
    tagForegroundColor:(UIColor *)tagForegroundColor tagBorderColor:(UIColor *)tagBorderColor{

    self.text = text;
    self.textColor = tagForegroundColor;
    self.backgroundColor = tagBackgroundColor;
    if(tagBorderColor){
        self.layer.borderColor = tagBorderColor.CGColor;
        self.layer.borderWidth = 0.5;
        self.layer.masksToBounds = YES;
    }
    [self sizeToFit];
    CGRect frame = self.frame;
    frame.size.width = frame.size.width + tagSideSpace*2;
    frame.size.height = frame.size.height +tagSideSpace*2;
    self.frame = frame;
    
}

@end
